<?php
/**
 * Zapp
 *
 * @version $Id: View.php 18 2010-09-13 04:20:05Z dm.barsukov@gmail.com $
 */

/**
 * @category   Zapp
 * @package    Zapp_Application
 * @copyright  Copyright (c) 2010 Zapp
 * @license    New BSD License
 */
class Zapp_Application_Resource_View extends Zend_Application_Resource_View
{
    public function getView()
    {
        if (null === $this->_view) {
            $options = $this->getOptions();
            $this->_view = new Zend_View($options);

            if (isset($options['doctype'])) {
                $this->_view->doctype()->setDoctype(strtoupper($options['doctype']));
            }

            if (isset($options['title'])) {
                $this->_view->headTitle($options['title']['value']);
                if (isset($options['title']['separator'])) {
                    $this->_view->headTitle()->setSeparator($options['title']['separator']);
                }
            }

            if (function_exists('iconv_set_encoding')) {
                iconv_set_encoding('internal_encoding', $this->_view->getEncoding());
            }

            if (function_exists('mb_internal_encoding')) {
                mb_internal_encoding($this->_view->getEncoding());
            }
        }

        return $this->_view;
    }
}
